import BeanDefinition from "@framework/bean/BeanDefinition";

/**
 * Bean工厂，负责管理IOC容器
 */
class BeanFactory {

    /**
     * 缓冲类池子
     */
    private beanDefinition: Map<string, BeanDefinition> = new Map();

    /**
     * 单例池
     */
    private singleton: Map<string, Object> = new Map();

    /**
     * 缓冲类池子
     */
    public getBeanDefinitions(): Map<string, BeanDefinition> {
        return this.beanDefinition;
    }

    /**
     * 获取单例池
     */
    public getSingleton(): Map<string, Object> {
        return this.singleton;
    }

    /**
     * 注册实例至IOC容器
     */
    public registerBean(beanName: string, bean: Object): void {
        this.singleton.set(beanName, bean);
    }

}

export default BeanFactory;